#include("../../comm/FormHead.html")
<div class="layui-fluid" style="padding-top:20px">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="card-search SearchTable">
                    <i class="layui-icon layui-icon-slider"></i> 当前位置 > 修改密码
                </div>
                <div class="layui-card-body " pad15>

                    <div class="layui-form" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">当前密码</label>

                            <div class="layui-input-inline">
                                <input type="password" name="oldPassword" lay-verify="required" lay-affix="eye" lay-verType="tips" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新密码</label>

                            <div class="layui-input-inline">
                                <input type="password" id="password" name="password" lay-verify="pass" lay-affix="eye" lay-verType="tips" autocomplete="off" id="LAY_password" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">6到16个字符</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认新密码</label>

                            <div class="layui-input-inline">
                                <input type="password" id="repassword" name="repassword" lay-verify="repass" lay-affix="eye" lay-verType="tips" autocomplete="off" class="layui-input">
                            </div>
                            <sapn class="layui-input-inline" style="padding-top: 13px;width: 400px">
                                <button lay-event="RandomPwd" class="layui-btn layui-btn-xs btn-change-13">随机生成</button>
                                <span id="pwdshow"></span>
                            </sapn>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="setmypass1">确认修改</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<script src="../../static/js/aes.min.js"></script>
<script src="../../static/js/base64.js"></script>
<script>
    //
    function encrypt(word) {
        var key = CryptoJS.enc.Utf8.parse("abcdefghijk12345");
        var srcs = (CryptoJS.enc.Utf8.parse(word));
        var encrypted = CryptoJS.AES.encrypt(srcs, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
        return Base64.encode(encrypted.toString());
    }

    layui.use(['form', 'myTool'], function () {
        var form = layui.form;
        form.on('submit(setmypass1)', function (data) {
            data.field.oldPassword = encrypt(data.field.oldPassword);
            data.field.password = encrypt(data.field.password);
            data.field.repassword = encrypt(data.field.repassword);
            layui.myTool.postJson("ChangePwdApi", data.field, function () {
                parent.layer.closeAll();
            });
            return false;
        });
        layui.util.event("lay-event", {
            RandomPwd: function () {
                layui.$.getJSON("getRandomPwdApi", {}, function (res) {
                    layui.$("#password").val(res.pwd);
                    layui.$("#repassword").val(res.pwd);
                    layui.$("#pwdshow").html("新密码：" + res.pwd);
                });
            }
        });
    });
</script>
</body>
</html>